﻿using Inovout.Kuajing.Models;
using Inovout.Repositories;
using NHibernate.Criterion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Kuajing.Repositories
{
    public class ShipmentOrderItemRepository : DataObjectRepository<ShipmentOrderItem>
    {
        public IList<ShipmentOrderItem> FindByStautsAndConsigner(string consigner)
        {
            var list = base.OpenSession().CreateCriteria<ShipmentOrderItem>()
                 .CreateCriteria("ShipmentOrder", "shipmentOrder")
                 .Add(Restrictions.Ge("shipmentOrder.Status", ShipmentOrderStatus.Paid))
                 .Add(Restrictions.Lt("shipmentOrder.Status", ShipmentOrderStatus.Shipped))
                 .Add(Restrictions.Eq("ExternalShipperId", consigner))
                .List<ShipmentOrderItem>();
            return list;
        }

        public IList<ShipmentOrderItem> FindByOrderNoAndConsigner(string consigner,string orderNo)
        {
            var list = base.OpenSession().CreateCriteria<ShipmentOrderItem>()
                 .CreateCriteria("ShipmentOrder", "shipmentOrder")
                 .Add(Restrictions.Eq("shipmentOrder.No", orderNo))
                 .Add(Restrictions.Eq("ExternalShipperId", consigner))
                .List<ShipmentOrderItem>();
            return list;
        }
    }
}
